package com.jxm.websocket.controller;

import com.jxm.websocket.config.WebSocket;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2023/6/30 10:34
 * @Version: 1.0
 */
@RestController
public class WebsocketTestController {

    @RequestMapping(value = "send.json")
    @ResponseBody
    public String base() {
        WebSocket.sendMessage("服务器消息推送");
        return "success";
    }

    @RequestMapping(value = "/mysocket", method = {RequestMethod.POST, RequestMethod.GET})
    public String socket(HttpServletRequest httpServletRequest, Model model) {
        return "mysocket";
    }
}
